﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PlanningGIS.Win.Controls
{
    /// <summary>
    /// 提示窗体
    /// </summary>
    public partial class FrmNotify : DevComponents.DotNetBar.Balloon
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public FrmNotify()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 加载窗体
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmNotify_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// 设置提示消息
        /// </summary>
        /// <param name="text"></param>
        public void SetText(string text)
        {
            if (lblMsg.InvokeRequired)
            {
                SetTextEvent v = new SetTextEvent(SetText);
                lblMsg.Invoke(v, text);
            }
            else
            {
                lblMsg.Text = text;
            }
        }
        /// <summary>
        /// 消息委托
        /// </summary>
        /// <param name="text"></param>
        private delegate void SetTextEvent(string text);

        /// <summary>
        /// 显示信息提示框
        /// </summary>
        /// <param name="message">要显示的消息</param>
        /// <param name="closetime">自动关闭的时间（秒）</param>
        public static void ShowNotify(string message, int closetime = 3)
        {
            FrmNotify alert = new FrmNotify();
            alert.SetText(message);
            Rectangle r = Screen.PrimaryScreen.WorkingArea;
            alert.Location = new System.Drawing.Point(r.Right - alert.Width, r.Bottom - alert.Height);
            alert.AutoClose = true;
            alert.AutoCloseTimeOut = closetime;
            alert.AlertAnimation = DevComponents.DotNetBar.eAlertAnimation.BottomToTop;
            alert.AlertAnimationDuration = 300;
            alert.Show(false);
        }
    }
}
